<!DOCTYPE html>

<html>
<head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
<meta http-equiv="Pragma" content="no-cache"> 
<meta http-equiv="Cache-Control" content="no-cache"> 
<meta http-equiv="Expires" content="0"> 
<title>后台登录</title> 
{load href="/static/admin/css/login.css" /}

</head> 
<body> 

<div class="login">
    <div class="message">后台管理登录</div>
    <div id="darkbannerwrap"></div>
    
    <form method="post" action="" id="form">
       <span style="color:red;padding-left: 10px;display: none" id="ts"></span>
        <input name="action" value="login" type="hidden">
        <input name="username" placeholder="用户名"  type="text">
        <hr class="hr15">
        <input name="password" placeholder="密码"  type="password">
        <hr class="hr15">
        <input name="verify" placeholder="验证码"  type="text" ><img src="{:url('admin/index/getverify')}" alt="" width="150" height="32" class="passcode" style="position:relative;top:-35px;left:190px; height:35px;cursor:pointer;" onclick="this.src=this.src+'?'+Math.random();">
        <hr class="hr15">
        {:token()}
        <input value="登录" style="width:100%;" id="btn" type="button">
        <hr class="hr20">
      
    </form>

    
</div>

<div class="copyright">© 2018品牌名称 by</div>


</body>
</html>
{load href="/static/jquery-3.3.1.min.js" /}

<script type="text/javascript">
    $("#btn").click(function(){

           var username=$("input[name='username']").val(),password=$("input[name='password']").val(),verify=$("input[name='verify']").val();         

             if(!username){
               $("#ts").html("*用户名不能为空").show(300).delay(3000).hide(300);
               return false;
            }

            if(!password){                
                $("#ts").html("*密码不能为空").show(300).delay(3000).hide(300);
                return false;
            }

            if(!verify){                
                $("#ts").html("*验证码不能为空").show(300).delay(3000).hide(300);
                return false;
            }else if(verify.length!=5){
                $("#ts").html("*验证码输入有误").show(300).delay(3000).hide(300);
                return false;
            }

            $.post("{:url('admin/index/checklogin')}",{"username":username,"password":password,"verify":verify},function(date){
                
                 
                if(date.code==200){
                    window.location.href="{:url('admin/index/index')}";
                }else{
                    $("#ts").html("*"+date.msg).show(300).delay(3000).hide(300);
                }
            })

    })

document.onkeydown=function(event){
    
    var e = event || window.event || arguments.callee.caller.arguments[0];
    
     if(e && e.keyCode==13){ // enter 键
        $("#btn").click();
    }
}; 
</script>